//
//  HomeDataCell.m
//  Ginix
//
//  Created by 冯志强 on 2025/2/20.
//

#import "HomeDataCell.h"

@interface HomeDataCell()
@property (nonatomic,strong) YYLabel * heartLabel;
@property (nonatomic,strong) YYLabel * hrvLabel;
@property (nonatomic,strong) YYLabel * oxLabel;
@property (nonatomic,strong) YYLabel * bodyLabel;
@end

@implementation HomeDataCell

-(void)setSubViewLayout{
    [super setSubViewLayout];
    
    self.titleLabel.text = @"健康数据";
    
    [self addSubview:self.heartLabel];
    [_heartLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_offset(CGSizeMake(140 * FMScaleX, 44 * FMScaleX));
        make.left.equalTo(self.bgview.mas_left).offset(25 * FMScaleX);
        make.top.equalTo(self.iconView.mas_bottom).offset(15 * FMScaleX);
    }];
    [self addSubview:self.hrvLabel];
    [_hrvLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.bgview.mas_right).offset(-25 * FMScaleX);
        make.size.centerY.equalTo(self.heartLabel);
    }];
    
    [self addSubview:self.oxLabel];
    [_oxLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.heartLabel.mas_bottom).offset(10 * FMScaleX);
        make.size.centerX.equalTo(self.heartLabel);

    }];
    [self addSubview:self.bodyLabel];
    [_bodyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.hrvLabel.mas_bottom).offset(10 * FMScaleX);
        make.size.centerX.equalTo(self.hrvLabel);
    }];
}

-(void)setInfoModel:(HomeQuickCheckModel *)infoModel{
    
    if (infoModel.heart.length > 0) {
        self.heartLabel.attributedText = [NSString formatHealthInfoWithHeartRate:@"心率： " secondString:infoModel.heart];
        self.heartLabel.textAlignment = NSTextAlignmentCenter;
    }
    if (infoModel.heartRota.length > 0) {
        self.hrvLabel.attributedText = [NSString formatHealthInfoWithHeartRate:@"HRV： " secondString:infoModel.heartRota];
        self.hrvLabel.textAlignment = NSTextAlignmentCenter;
    }
    if (infoModel.temp.length > 0) {
        self.bodyLabel.attributedText = [NSString formatHealthInfoWithHeartRate:@"体温： " secondString:infoModel.temp];
        self.bodyLabel.textAlignment = NSTextAlignmentCenter;
    }
    if (infoModel.q2.length > 0) {
        self.oxLabel.attributedText = [NSString formatHealthInfoWithHeartRate:@"血氧： " secondString:[NSString stringWithFormat:@"%@%%",infoModel.q2]];
        self.oxLabel.textAlignment = NSTextAlignmentCenter;
    }
}

-(YYLabel *)heartLabel{
    
    if (!_heartLabel) {
        _heartLabel = [[YYLabel alloc]init];
        _heartLabel.backgroundColor = RDRGB(0xF5F2ED);
        [_heartLabel setCornerRadius:6 * FMScaleX];
        _heartLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _heartLabel ;
}

-(YYLabel *)hrvLabel{
    
    if (!_hrvLabel) {
        _hrvLabel = [[YYLabel alloc]init];
        _hrvLabel.backgroundColor = RDRGB(0xF5F2ED);
        [_hrvLabel setCornerRadius:6 * FMScaleX];
        _hrvLabel.textAlignment = NSTextAlignmentCenter;

    }
    return _hrvLabel ;
}

-(YYLabel *)oxLabel{
    
    if (!_oxLabel) {
        _oxLabel = [[YYLabel alloc]init];
        _oxLabel.backgroundColor = RDRGB(0xF5F2ED);
        [_oxLabel setCornerRadius:6 * FMScaleX];
        _oxLabel.textAlignment = NSTextAlignmentCenter;

    }
    return _oxLabel ;
}

-(YYLabel *)bodyLabel{
    
    if (!_bodyLabel) {
        _bodyLabel = [[YYLabel alloc]init];
        _bodyLabel.backgroundColor = RDRGB(0xF5F2ED);
        [_bodyLabel setCornerRadius:6 * FMScaleX];
        _bodyLabel.textAlignment = NSTextAlignmentCenter;

    }
    return _bodyLabel ;
}

@end
